'use strict';
const dayjs = require("dayjs");
module.exports = app => {
  const { STRING, INTEGER, TINYINT } = app.Sequelize;
    return app.model.define(
      'beefModel',
      {
          id: {type: INTEGER, primaryKey: true, autoIncrement: true},
          /**
           * `beefno` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '肉牛编号',
           *   `sex` varchar(10) DEFAULT NULL COMMENT '性别',
           *   `beeftype` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '畜别',
           *   `breed` varchar(20) DEFAULT NULL COMMENT '品种',
           *   `birthday` date DEFAULT NULL COMMENT '出生日期',
           *   `parentno` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '父本',
           *   `motherno` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '母本',
           *   `family` varchar(10) DEFAULT NULL COMMENT '家系',
           *   `company` int DEFAULT NULL COMMENT '所在公司',
           *   `status` varchar(20) DEFAULT NULL COMMENT '状态',
           *   `transin` date DEFAULT NULL COMMENT '入场时间',
           *   `version` int DEFAULT '1',
           *   `is_deleted` tinyint(1) DEFAULT '0',
           */
            beefno: STRING(20),
            sex: STRING(10),
            beeftype: STRING(20),
            breed: STRING(20),
            birthday: {
                type: app.Sequelize.DATE,
                allowNull: true,
                get() {
                    return dayjs(this.getDataValue('birthday')).format('YYYY-MM-DD');
                }
            },
            parentno: STRING(20),
            motherno: STRING(20),
            family: STRING(10),
            company: INTEGER,
            status: STRING(20),
            transin: {
                type: app.Sequelize.DATE,
                allowNull: true,
                get() {
                    return dayjs(this.getDataValue('transin')).format('YYYY-MM-DD');
                }
            },
            version: INTEGER,
            is_deleted: TINYINT(1),

      },
      {
          tableName: 'beef',
          timestamps: true, // 启用时间戳(createdAt, updatedAt)
          updatedAt: false, // 不想要 updatedAt
          createdAt: false, // 想要  createdAt 但是希望名称叫做 created_at
      }
  );
};
